<template>
  <div v-if="permission">
    <div class="med-container">
      <label class="med-item">State</label>
      <span class="med-item">
        <span>{{ state }}</span>
        <button class="btn btn-primary btn-xs" @click="toggleForm()">
          Resolve ✔
        </button>
      </span>
    </div>
    <div v-if="show" class="med-container">
      <form class="med-row">
        <button class="btn btn-lg btn-primary btn-block">
          Click to confirm
        </button>
      </form>
    </div>
  </div>
  <div v-else>
    <p>State: {{ state }}</p>
  </div>
</template>

<script>
export default {
  name: "Resolve",
  props: ["permission", "state"],
  data() {
    return {
      show: false
    };
  },
  methods: {
    toggleForm: function() {
      if (this.show) {
        this.show = false;
      } else {
        this.show = true;
      }
    }
  }
};
</script>

<style scoped>
.med-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  background-color: #eeeeee;
}

.med-item {
  width: 40%;
  margin-bottom: 2%;
}

.med-item + .med-item,
.med-alert + button {
  margin-left: 2%;
}

.med-row {
  width: 100%;
  margin-bottom: 2%;
}

.med-alert {
  color: red;
  font-weight: bolder;
}
</style>
